package com.vincent.template.controller.manage;

import com.vincent.template.dto.sys.bind.BindAuthGroupAuthDto;
import com.vincent.template.dto.sys.bind.BindAuthUriDto;
import com.vincent.template.dto.sys.bind.BindRoleAuthDto;
import com.vincent.template.dto.sys.bind.BindRoleAuthGroupDto;
import com.vincent.template.dto.sys.bind.BindUserGroupRoleDto;
import com.vincent.template.dto.sys.bind.BindUserGroupUserDto;
import com.vincent.template.dto.sys.bind.BindUserRoleDto;
import com.vincent.template.service.logic.BindService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Vincent Wang
 * @date 2021/3/26 15:30
 */
@Api(tags = "绑定管理")
@RestController
@RequestMapping("/manage/bind")
public class BindController {

    @Autowired
    private BindService bindService;

    @ApiOperation("绑定/解绑 用户组和用户")
    @PostMapping("/userGroupUser")
    public boolean bindUserGroupUser(@Validated @RequestBody BindUserGroupUserDto dto,
                                     @RequestParam(value = "unbind", defaultValue = "false") boolean unbind) {
        return bindService.bindUserGroupUser(dto, unbind);
    }

    @ApiOperation("绑定/解绑 用户和角色")
    @PostMapping("/userRole")
    public boolean bindUserRole(@Validated @RequestBody BindUserRoleDto dto,
                                @RequestParam(value = "unbind", defaultValue = "false") boolean unbind) {
        return bindService.bindUserRole(dto, unbind);
    }

    @ApiOperation("绑定/解绑 用户组和角色")
    @PostMapping("/userGroupRole")
    public boolean bindUserGroupRole(@Validated @RequestBody BindUserGroupRoleDto dto,
                                     @RequestParam(value = "unbind", defaultValue = "false") boolean unbind) {
        return bindService.bindUserGroupRole(dto, unbind);
    }

    @ApiOperation("绑定/解绑 角色和权限")
    @PostMapping("/roleAuth")
    public boolean bindRoleAuth(@Validated @RequestBody BindRoleAuthDto dto,
                                @RequestParam(value = "unbind", defaultValue = "false") boolean unbind) {
        return bindService.bindRoleAuth(dto, unbind);
    }

    @ApiOperation("绑定/解绑 角色和权限组")
    @PostMapping("/roleAuthGroup")
    public boolean bindRoleAuthGroup(@Validated @RequestBody BindRoleAuthGroupDto dto,
                                     @RequestParam(value = "unbind", defaultValue = "false") boolean unbind) {
        return bindService.bindRoleAuthGroup(dto, unbind);
    }

    @ApiOperation("绑定/解绑 权限组和权限")
    @PostMapping("/authGroupAuth")
    public boolean bindAuthGroupAuth(@Validated @RequestBody BindAuthGroupAuthDto dto,
                                     @RequestParam(value = "unbind", defaultValue = "false") boolean unbind) {
        return bindService.bindAuthGroupAuth(dto, unbind);
    }

    @ApiOperation("绑定/解绑 权限和uri")
    @PostMapping("/authUri")
    public boolean bindAuthUri(@Validated @RequestBody BindAuthUriDto dto,
                               @RequestParam(value = "unbind", defaultValue = "false") boolean unbind) {
        return bindService.bindAuthUri(dto, unbind);
    }
    
}
